package git.determinal.template.view;




import java.sql.Date;
import java.sql.Time;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;

public class DateUtil {
    private static SimpleDateFormat DATE_TIME_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    private static SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd");
    private static SimpleDateFormat TIME_FORMAT = new SimpleDateFormat("HH:mm:ss");

    public DateUtil() {
    }

    public static Timestamp toDateTime(String value) {
        Timestamp datetime = null;

        try {
            datetime = new Timestamp(DATE_TIME_FORMAT.parse(value).getTime());
        } catch (Exception var3) {
            var3.printStackTrace();
        }

        return datetime;
    }

    public static Date toDate(String value) {
        Date date = null;

        try {
            date = new Date(DATE_FORMAT.parse(value).getTime());
        } catch (Exception var3) {
            var3.printStackTrace();
        }

        return date;
    }

    public static Time toTime(String value) {
        Time time = null;

        try {
            time = new Time(TIME_FORMAT.parse(value).getTime());
        } catch (Exception var3) {
            var3.printStackTrace();
        }

        return time;
    }

    public static String format(java.util.Date date, String format) {
        SimpleDateFormat sdf = new SimpleDateFormat(format);
        return sdf.format(date);
    }
}

